﻿using AutoMapper;
using Microsoft.AspNetCore.Http;
using rbac.Contracts.DTO.Input;
using rbac.Contracts.DTO.Output;
using rbac.Contracts.Interface;
using rbac.Domain.Entity;
using rbac.Domain.Interface;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace rbac.Services
{
    public class RoleService: ServiceBase, IRoleService
    {
        IRoleRepository _roleRepository;


        public RoleService(IRoleRepository roleRepository)
        {
            _roleRepository = roleRepository;
      
        }
        public List<RoleOutput> SearchRoles(string roleName)
        {
            var roles=_roleRepository.SerrchRoles(roleName);
            return _mapper.Map<List<RoleOutput>>(roles);
        }


        public int Add(RoleInput role)
        {
            var entity = _mapper.Map<Role>(role);
            return _roleRepository.Add(entity);


        }
        public int Update(RoleInput role)
        {
            return _roleRepository.Update(_mapper.Map<Role>(role));
        }
        public int Delete(params int[] idList)
        {
         
            return _roleRepository.Delete(idList);
        }
    }
}
